package com.bjb.vr.operation.controller;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bjb.vr.common.ao.StatisticAo;
import com.bjb.vr.common.result.BaseResult;
import com.bjb.vr.common.result.CommonResult;
import com.bjb.vr.common.vo.OptCusDevDetailVo;
import com.bjb.vr.common.vo.StatisticVo;
import com.bjb.vr.operation.service.SysStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 运营端数据统计
 *
 * @author: HuJingBo
 * @time: 2022/11/30 11:38
 */
@RestController
@RequestMapping("/api/operation/v1")
public class SysDataStatisticsController {


	@Autowired
	private SysStatisticsService statisticsService;

	/**
	 * 统计在线离线设备
	 *
	 * @return
	 */
	@PostMapping("/statistics/devices")
	public BaseResult devicesCount(@RequestBody StatisticAo statisticAo) {
		JSONArray devicesCount = statisticsService.devicesCount(statisticAo);
		return CommonResult.Ok().setResult(devicesCount);
	}

	/**
	 * 统计在线离线设备--根据条件
	 *
	 * @return
	 */
	@PostMapping("/statistics/devicesByCondition")
	public BaseResult devicesCountByCondition(@RequestBody StatisticAo statisticAo) {
		JSONArray devicesCount = statisticsService.devicesCountByCondition(statisticAo);
		return CommonResult.Ok().setResult(devicesCount);
	}

	/**
	 * 课程资源统计--教育版
	 */
	@PostMapping("/statistics/resources/education")
	public BaseResult resourcesCountEdu(@RequestBody StatisticAo statisticAo) {
		JSONArray resourcesCount = statisticsService.resourcesCountEdu(statisticAo);
		return CommonResult.Ok().setResult(resourcesCount);
	}

	/**
	 * 课程资源统计--党建版
	 */
	@PostMapping("/statistics/resources/party")
	public BaseResult resourcesCountParty(@RequestBody StatisticAo statisticAo) {
		JSONArray resourcesCount = statisticsService.resourcesCountParty(statisticAo);
		return CommonResult.Ok().setResult(resourcesCount);
	}

	/**
	 * 课程资源详情--课程资源使用数据
	 */
	@PostMapping("/statistics/resources/dataDetail")
	public BaseResult resourcesDataDetail(@RequestBody StatisticAo statisticAo) {
		IPage<StatisticVo> voIPage = statisticsService.resourcesDataDetail(statisticAo);
		return CommonResult.Ok().setResult(voIPage);
	}

	/**
	 * 课程资源详情--客户使用数据
	 */
	@PostMapping("/statistics/resources/detail")
	public BaseResult resourcesDetail(@RequestBody StatisticAo statisticAo) {
		IPage<StatisticVo> voIPage = statisticsService.resourcesDetail(statisticAo);
		return CommonResult.Ok().setResult(voIPage);
	}

	/**
	 * 课程资源总计使用次数
	 */
	@PostMapping("/statistics/resources/totalCount")
	public BaseResult resourcesTotalCount(@RequestBody StatisticAo statisticAo) {
		Integer totalUseCount = statisticsService.resourcesTotalCount(statisticAo);
		return CommonResult.Ok().setResult(totalUseCount);
	}
}
